<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@ page import="java.util.*" %>
<%@ page import="org.swim.entity.Ability" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
	<title>Manage Abilities</title>
	<link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
</head>
<body>
	<%@ include file="NavBar.jsp" %>
	<div class="container">
	<h1>Manage Abilities</h1>
	<% try {
		String errors = (String) request.getAttribute("errors");
		if (errors.equals("abilityAlreadyExists"))
		 { 
	%>
		<div class="row">
		<div class="alert alert-error"><strong>Error:</strong> the ability already exists</div>
		</div>
	<% } else if(errors.equals("noAbility")) { %>
		<div class="row">
			<div class="alert alert-error"><strong>Error:</strong> please insert a name</div>
		</div>		
	<%	} } catch (NullPointerException e) {
		
	} %>
		<div class="row">
		<h2>Remove an Ability</h2>
		<form action="RemoveAbility" method="post">
		<% 
			try {
				List<Ability> abilities = (List<Ability>) request.getAttribute("abilities");  
			if (!(abilities.size()==0)) {
			for (Ability current:abilities) {
		%>
		<label class="radio">
			<input type="radio" name="id" value="<% out.print(current.getIdAbilita()); %>"><% out.print(current.getNome()); %>
		</label>	
		<%	} %>
			<button type="submit" class="btn btn-danger">Remove</button>			
		<%	} } catch (NullPointerException e) {
				
			} 
		%>
		</form>	
		</div>
		<div class="row">
			<h2>Add new Abilities</h2>
			<a href="AddAbility"><button class="btn btn-success" type="button">Add Abilities</button></a>	
		</div>		
	</div>
</body>
</html>